﻿using Mes.Domain.BoundedContext.EntityBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Domain.BoundedContext.Entities.WorkOrders
{
    public class ItemCons : NoIdEntityBase
    {
        public ItemCons() { }

        /// <summary>
        /// 工单编号
        /// Identify work order
        /// </summary>
        public string? Wo_Id { get; set; }

        /// <summary>
        /// 操作编号
        /// Identify operation
        /// </summary>
        public string? Oper_Id { get; set; }

        /// <summary>
        /// 排班开始Utc时间
        /// Timestamp of shift start
        /// </summary>
        public DateTime? Shift_Start_Utc { get; set; }

        /// <summary>
        /// 排班开始本地时间
        /// Timestamp of shift start
        /// </summary>
        public DateTime? Shift_Start_Local { get; set; }

        /// <summary>
        /// 物料ID（消耗品）
        /// Identifier of consumed item
        /// </summary>
        public int Item_Id { get; set; }

        /// <summary>
        /// 批号
        /// Lot number of consumed item
        /// </summary>
        public string? Lot_No { get; set; }

        /// <summary>
        /// 父物料批号
        /// Lot number of parent item
        /// </summary>
        public string? Fg_Lot_No { get; set; }

        /// <summary>
        /// 物料的分批号（消耗品）
        /// Sublot number of consumed item
        /// </summary>
        public string? Sublot_No { get; set; }

        /// <summary>
        /// 父物料的分批号
        /// Sublot number of parent item
        /// </summary>
        public string? Fg_Sublot_No { get; set; }

        /// <summary>
        /// 消费原因
        /// Reason for consumption
        /// </summary>
        public int? Reas_Cd { get; set; }

        /// <summary>
        /// 用户ID
        /// ID of user making this entry
        /// </summary>
        public string User_Id { get; set; }=String.Empty;

        /// <summary>
        /// 是否取消
        /// Flag if wastage 
        /// </summary>
        public bool Item_Scrapped { get; set; }

        /// <summary>
        /// 运行的实体
        /// On which entity job ran
        /// </summary>
        public int? Ent_Id { get; set; }

        /// <summary>
        /// 排班ID
        /// Shift identifier
        /// </summary>
        public int? Shift_Id { get; set; }

        /// <summary>
        /// 物料的等级编码（消耗品）
        /// Grade code of consumed items
        /// </summary>
        public int Grade_Cd { get; set; }

        /// <summary>
        /// 状态编号
        /// Status code of consumed items
        /// </summary>
        public int Status_Cd { get; set; }

        /// <summary>
        /// 存储位置
        /// Storage entity from which items consumed
        /// </summary>
        public int? From_Ent_Id { get; set; }

        /// <summary>
        /// 消耗量
        /// Qty used
        /// </summary>
        public double Qty_Cons { get; set; }

        /// <summary>
        /// 用于ERP的消耗量
        /// Qty used txd to ERP
        /// </summary>
        public double Qty_Cons_Erp { get; set; }

        /// <summary>
        /// 参考外部系统
        /// Reference to external system 
        /// </summary>
        public string? Ext_Ref { get; set; }

        /// <summary>
        /// 交易类型
        /// 0 = normal consumption, 1 = lot split, 2 = lot combination
        /// </summary>
        public int Transaction_Type { get; set; }

        /// <summary>
        /// PEM段内谱系ID
        /// PEM intra-segment genealogy ID
        /// </summary>
        public string? Genealogy_Id { get; set; }

        /// <summary>
        /// 链接到上游段正在消耗的生产
        /// Link to upstream segment production being consumed
        /// </summary>
        public string? Upstream_Event_Id { get; set; }

        /// <summary>
        /// S95段需求ID
        /// S95 segment requirement ID
        /// </summary>
        public string? Segment_Requirement_Id { get; set; }

        /// <summary>
        /// S95段响应ID
        /// S95 segment response ID
        /// </summary>
        public string? Segment_Response_Id { get; set; }

        /// <summary>
        /// 注释
        /// Comment field
        /// </summary>
        public string? Comments { get; set; }

        /// <summary>
        /// 备用字段1
        /// Use defined by language term 596
        /// </summary>
        public string? Spare1 { get; set; }

        /// <summary>
        /// 备用字段2
        /// Use defined by language term 597
        /// </summary>
        public string? Spare2 { get; set; }

        /// <summary>
        /// 备用字段3
        /// Use defined by language term 598
        /// </summary>
        public string? Spare3 { get; set; }

        /// <summary>
        /// 备用字段4
        /// Use defined by language term 599
        /// </summary>
        public string? Spare4 { get; set; }

        /// <summary>
        /// 最新编辑原因
        /// Why record was changed
        /// </summary>
        public string? Last_Edit_Comment { get; set; }

        /// <summary>
        /// 最新编辑用户
        /// Who last changed record
        /// </summary>
        public string Last_Edit_By { get; set; }=String.Empty;

        /// <summary>
        /// 最新编辑时间
        /// When record was last changed
        /// </summary>
        public DateTime Last_Edit_At { get; set; } = DateTime.Now;

        /// <summary>
        /// 创建UTC时间
        /// When record was created
        /// </summary>
        public DateTime Created_At_Utc { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 创建本地时间
        /// When record was created
        /// </summary>
        public DateTime Created_At_Local { get; set; } = DateTime.Now;

        /// <summary>
        /// 行ID
        /// Unique identifier for row 
        /// </summary>
        public int Row_Id { get; set; }
    }
}
